const address = [
  {
    id: 1,
    name: '北京市',
    children: [
      {
        id: 11,
        name: '海淀区',
        children: [
          {
            id: 111,
            name: '中关村'
          }
        ]
      },
      {
        id: 12,
        name: '朝阳区'
      }
    ]
  },
  {
    id: 2,
    name: '河北省'
  }
]

function getNameById (address, id) {
  let addressIdName = ''
  address.forEach(item => {
    if (item.id === id) {
      // eslint-disable-next-line no-const-assign
      addressIdName = item.name
    } else if (item.children && item.children.length && !addressIdName) {
      addressIdName = getNameById(item.children, id)
    }
  })
  return addressIdName
}
const a = getNameById(address, 111)
console.log(a)
